package com.haiertvbic.tvnow.util;

import android.view.Display;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.TranslateAnimation;

import com.haiertvbic.tvnow.R;

/**
 * 
 * @author 李彬
 * 
 */
public class SetActivityView {
	public static View setActivityView(Window activity_window,
			WindowManager window_manager) {
		return setActivityView(activity_window, window_manager, 0);
	}

	public static View setActivityView(Window activity_window,
			WindowManager window_manager, int width) {
		View activity_view = activity_window.getDecorView();

		WindowManager.LayoutParams lp = activity_window.getAttributes();
		Display tv_display = window_manager.getDefaultDisplay();
		if (width == 0) {
			lp.width = tv_display.getWidth() / 5;
		}else {
			lp.width = width;
		}
		lp.height = tv_display.getHeight();
		lp.gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL;
		activity_window.setAttributes(lp);
		// ============================
		TranslateAnimation traslate = new TranslateAnimation(lp.width * 5,
				lp.width, 0, 0);
		traslate.setDuration(1000);
		activity_view.startAnimation(traslate);
		return activity_view;
	}

	public static View setActivityViewTvwa(Window activity_window,
			WindowManager window_manager) {
		View activity_view = activity_window.getDecorView();
		activity_view.setBackgroundResource(R.drawable.sound_bg);
		activity_view.getBackground().setAlpha(180);

		WindowManager.LayoutParams lp = activity_window.getAttributes();
		Display tv_display = window_manager.getDefaultDisplay();
		lp.width = tv_display.getWidth() / 4;
		lp.height = tv_display.getHeight() / 4 * 3;
		lp.gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL;
		activity_window.setAttributes(lp);
		return activity_view;
	}
}
